package com.sunwayworld.dev.core.db.dialect;

import java.sql.Connection;
import java.sql.SQLException;

public class TableEngineFactory {

	private static TableEngine tableEngine;

	public static TableEngine getInstance(String tableName, Connection conn)
			throws SQLException {
		

		if ("Microsoft SQL Server".equalsIgnoreCase(conn.getMetaData()
				.getDatabaseProductName())) {

			tableEngine = new SQLServerTableEngine(tableName, conn);

		} else if ("MySQL".equalsIgnoreCase(conn.getMetaData()
				.getDatabaseProductName())) {
			tableEngine = new MySQLTableEngine(tableName, conn);
		} else {

			tableEngine = new OracleTableEngine(tableName, conn);
		}

		return tableEngine;
	}

	public static TableEngine getInstance(Connection conn) throws SQLException {
		if ("Microsoft SQL Server".equalsIgnoreCase(conn.getMetaData()
				.getDatabaseProductName())) {

			tableEngine = new SQLServerTableEngine(conn);

		} else {
			tableEngine = new OracleTableEngine(conn);
		}

		return tableEngine;
	}
}
